package com.shopping.mall.core.module.order.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.shopping.mall.core.module.cart.entity.CartList;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotNull;
import java.sql.Timestamp;

/**
* Order实体类
*
* @author zzy
* @date 2021-08-29
*/
@Data
@TableName("orders")
public class Order {

    public void setPlace(String country, String province, String city, String district, String address, String title, String email, String recipients, String phone,String others,String newCity) {
        this.country=country;
        this.province=province;
        this.city=city;
        this.district=district;
        this.address=address;
        this.title=title;
        this.phone=phone;
        this.email=email;
        this.recipients=recipients;
        this.others=others;
        this.newCity=newCity;
    }

    public interface insert{
    }

    public interface update{
    }

    @ApiModelProperty(value="商品信息")
    private String goods;

    @ApiModelProperty(value="快递信息")
    private String delivery;

    @ApiModelProperty(value="paypal订单号")
    private String outTradeNo;

    private String others;

    private String newCity;

    @ApiModelProperty(value="收件人")
    private String recipients;

    @ApiModelProperty(value="title")
    private String title;

    @ApiModelProperty(value="address")
    private String address;

    @ApiModelProperty(value="email")
    private String email;

    @ApiModelProperty(value="district")
    private String district;

    @ApiModelProperty(value="city")
    private String city;

    @ApiModelProperty(value="province")
    private String province;

    @ApiModelProperty(value="country")
    private String country;

    @ApiModelProperty(value="完成方式（1为用户确定，2为自动）")
    private Integer finishWay;

    @ApiModelProperty(value="完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp finishAt;

    @ApiModelProperty(value="自动完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp autoFinishAt;

    @ApiModelProperty(value="发货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp deliverAt;

    @ApiModelProperty(value="支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp payAt;

    @ApiModelProperty(value="订单状态（1为待支付，2为已支付待发货，3为已发货，4为已收货）")
    private Integer state;

    @ApiModelProperty(value="订单编号")
    private String orderNumber;

    @ApiModelProperty(value="修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updateAt;

    @ApiModelProperty(value="创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createAt;

    @ApiModelProperty(value="总价格")
    private Double totalPrice;

    @ApiModelProperty(value="运费")
    private Double freightPrice;

    @ApiModelProperty(value="商品价格")
    private Double goodsPrice;

    @ApiModelProperty(value="手机号")
    private String phone;

    @ApiModelProperty(value="用户ID")
    private String userId;

    @ApiModelProperty(value="主键")
    @TableId(type = IdType.UUID)
    private String id;


    public void setCart(CartList cart) {
        this.freightPrice=cart.getFreightPrice();
        this.goodsPrice=cart.getGoodsPrice();
        this.totalPrice=cart.getTotalPrice();
    }


//    public void setTotalPrice() {
//        totalPrice=goodsPrice+freightPrice;
//    }



}
